import React from 'react';
import styles from './index.less';
import { history } from 'umi';

const Header = () => {
  const userName = localStorage.getItem('username');
  return (
    <div className={styles.header}>
      <h1 className={styles.headerTitle}>PRACTICE</h1>
      <div className={styles.headerRight}>
        <div>{userName}</div>
        <div
          className={styles.logOut}
          onClick={() => {
            localStorage.setItem('token', '');
            localStorage.setItem('username', '');
            history.push('/login');
          }}
        >
          注销
        </div>
      </div>
    </div>
  );
};

export default Header;
